package checker

import (
	"kumachan/interpreter/lang/textual/ast"
	"kumachan/interpreter/lang/common/source"
	"kumachan/interpreter/compiler/checker/checked"
	"kumachan/interpreter/compiler/checker/typsys"
)


func (CheckedExprTerm) Term() {}
type CheckedExprTerm struct {
	Expr  *checked.Expr
}
func MakeCheckedExprTerm(expr *checked.Expr) ast.VariousTerm {
	return ast.VariousTerm {
		Node: ast.NodeFromLocation(expr.Info.Location),
		Term: CheckedExprTerm { Expr: expr },
	}
}
func checkCheckedExpr(T CheckedExprTerm) ExprChecker {
	return makeExprChecker(T.Expr.Info.Location, func(cc *checkContext) checkResult {
		return cc.assignExpr(T.Expr)
	})
}

func (ConstructorCallTerm) Term() {}
type ConstructorCallTerm struct {
	TypeDef   *typsys.TypeDef
	TypeArgs  [] typsys.Type
	Argument  ast.Expr
}
func checkConstructorCall(C ConstructorCallTerm, loc source.Location) ExprChecker {
	return makeExprChecker(loc, func(cc *checkContext) checkResult {
		var callee = C.TypeDef
		var params = C.TypeArgs
		var arg = C.Argument
		return callConstructor(cc, callee, params, arg)
	})
}


